﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

using PortalIntranet.DatabaseComponents.Comun;
using System.Data.Entity.ModelConfiguration;

namespace PortalIntranet.DatabaseComponents.Administracao
{
	[Serializable]
	[Table("Portlets")]
	public class Portlet : Entidade
	{
		public Portlet()
		{
		}

		[Required, MaxLength(50)]
		public string Nome { get; set; }

		public LinhaPortlet Linha { get; set; }

		public LarguraPortlet Largura { get; set; }

		public int Ordem { get; set; }

		#region TipoLayout
		public int TipoLayoutId { get; set; }

		public virtual TipoLayout TipoLayout { get; set; }
		#endregion
	}

	internal class PortletConfiguration : EntityTypeConfiguration<Portlet>
	{
		internal PortletConfiguration()
		{
			this.HasOptional(i => i.TipoLayout)
				.WithMany(u => u.Portlets)
				.HasForeignKey(i => i.TipoLayoutId);
		}
	}
}
